package com.example.demo.javaTest;

import com.example.demo.anno.MyDefined;
import org.junit.jupiter.api.Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

@MyDefined(value="a",aaa = 99.9,bbb={"a","b","c"})
public class Anno {

    @MyDefined(value="a1",aaa = 11.1,bbb={"a1","b1","c1"})
    @Test
    public void testAnnotation() throws NoSuchMethodException {
        Class c = Anno.class;
        Method m = c.getDeclaredMethod("testAnnotation");
        if(c.isAnnotationPresent(MyDefined.class)){
            MyDefined myDefined = (MyDefined) c.getDeclaredAnnotation(MyDefined.class);
            System.out.println(myDefined.value());
            System.out.println(myDefined.aaa());
            System.out.println(Arrays.toString(myDefined.bbb()));
        }
        if(m.isAnnotationPresent(MyDefined.class)){
            MyDefined myDefined = (MyDefined) m.getDeclaredAnnotation(MyDefined.class);
            System.out.println(myDefined.value());
            System.out.println(myDefined.aaa());
            System.out.println(Arrays.toString(myDefined.bbb()));
        }
    }
}
